Skip to content

feat(patterns): add temporal_rhythm detector (seventh deterministic detector) (#20) - #39

Open
Sarcastic-Soul wants to merge 2 commits into
nossa-y:mainfrom
Sarcastic-Soul:feat/temporal-rhythm-detector
Open

feat(patterns): add temporal_rhythm detector (seventh deterministic detector) (#20)#39
Sarcastic-Soul wants to merge 2 commits into
nossa-y:mainfrom
Sarcastic-Soul:feat/temporal-rhythm-detector

Conversation

@Sarcastic-Soul

Copy link
Copy Markdown
Contributor

Closes #10. Re-submits #20 on fresh main base with review feedback addressed.

Summary

Adds temporal_rhythms() as the seventh deterministic detector in src/activity_frames/patterns.py.

What it does

Clusters focused app frames by local 30-minute hour bins across calendar days. Emits WorkPattern(kind="temporal_rhythm") when:

  • A bin/span is hit on $\ge 3$ distinct days (MIN_DAYS_FOR_RHYTHM = 3)
  • Regularity $\ge 0.60$ (fraction of active days in the window that hit the bin)

Adjacent qualifying bins per app are merged into a single contiguous span before the global [:12] cut, preventing an always-focused app from occupying all output slots.

Example label:
Cursor active 09:00-10:00 on 5/5 days (regularity 1.00)

Review Feedback Addressed (from #20)

  • Adjacent Bin Merging: Merges contiguous qualifying 30-minute bins per app into one WorkPattern block before the [:12] cut.
  • SQL Query Guard: Added LIMIT 50000 to the SQL query.
  • Docstring Formula: Aligned docstring formula to distinct_days_hit / total_active_days_in_window.
  • Scope: Hour-of-day clustering only (no inter-occurrence intervals).

Tier Contract (SPEC §7)

The label carries observed time windows and a regularity score only — no interpretation or intent labels (e.g., "morning routine"). The detector remains strictly Tier-1 (measured, deterministic).

Checklist

  • Output stays deterministic (no clock, network, randomness, or model calls)
  • New behavior has a test; pytest -q passes
  • New schema fields, if any, are measured - or live in the tier-2 inferred block with a confidence tag
  • No typed text or page content is emitted by default

@nossa-y
nossa-y force-pushed the main branch 3 times, most recently from 972b4d9 to e92e599 Compare August 6, 2026 18:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature: Temporal Rhythm Detector

2 participants